package io.renren.modules.crawler.utils;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.util.EntityUtils;

/**
 * Created by zhangheng on 2017/9/20.
 */
public class URLFecter {

    public static String URLParser(HttpClient client, String url) throws Exception{
        HttpResponse response = HTTPUtils.getRawHtml(client, url);
        int statusCode = response.getStatusLine().getStatusCode();
        String entity = null;
        if(statusCode == 200){
            entity = EntityUtils.toString(response.getEntity(),"utf-8");
        }else{
            EntityUtils.consume(response.getEntity());
        }
        return entity;
    }
}
